package aam.model.subboard;

import java.util.HashMap;
import java.util.List;

import javax.annotation.Resource;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class SubBoardDaoImpl implements SubBoardDao {
	@Resource(name="sqlSessionTemplate")
	private SqlSessionTemplate sqlSessionTemplate;

		@Override
		public List<SubBoardVO> getAllGuestBookList(int p) throws Exception {
			return this.sqlSessionTemplate.selectList("subBoard.getAllGuestBookList",p);
		}

		@Override
		public int getBoardTotalConunt() throws Exception {
			return this.sqlSessionTemplate.selectOne("subBoard.getBoardTotalConunt");
		}
	
		@Override
		public int writeGuestBook(HashMap map) throws Exception {
			return this.sqlSessionTemplate.insert("subBoard.writeGuestBook",map);
		}
		
		@Override
		public int deleteGuestBook(int no) throws Exception {
			return this.sqlSessionTemplate.delete("subBoard.deleteGuestBook", no);
		}
	
		
		@Override
		public void writeReply(SubBoardVO vo) throws Exception {
			 sqlSessionTemplate.insert("subBoard.writeReply",vo);
			
		}
	
		@Override
		public List<SubBoardVO> getReplyByNo(int no) throws Exception {
			return sqlSessionTemplate.selectList("subBoard.getReplyByNo",no);
		}

		@Override
		public void deleteReply(int replyNo) throws Exception {
			sqlSessionTemplate.delete("subBoard.deleteReply",replyNo);
			
		}
		
		@Override
		public List<SubBoardVO> replyPaging(HashMap map) throws Exception {
			return sqlSessionTemplate.selectList("subBoard.replyPaging",map);
		}

		@Override
		public int getReplyTotalConunt(int no) throws Exception {
			return sqlSessionTemplate.selectOne("subBoard.getReplyTotalConunt",no);
		}
		
		@Override
		public void updatePointWriteReply(String memberId) throws Exception {
			sqlSessionTemplate.update("subBoard.updatePointWriteReply", memberId);
			
		}

		@Override
		public void insertReport(String no) throws Exception {
			sqlSessionTemplate.insert("subBoard.insertReport", no);
		}

		@Override
		public int updateReport(String no) throws Exception {
			return sqlSessionTemplate.update("subBoard.updateReport",no);
		}

		@Override
		public List selectReport() throws Exception {
			return sqlSessionTemplate.selectList("subBoard.selectReport");
		}
	
}
